1. Field of the Invention
This invention relates generally to the field of software development using multiple languages and more particularly to a preprocessing technique for assuring consistency of global constants in a multilanguage environment.
2. Background of the Invention
Many large software development projects require that their systems product be generated from many different types of source files. On some occasions large software system could be generated through the use of multiple languages. There are various reasons why a single source language might not be sufficient for the generation and maintenance of software systems. For example, the system could be interfacing with another system supplied by an external vendor, and the interface definition could possibly be in a different language than the "native" language of the software system. Or, certain parts of the system could be written in a faster, lower-level language (such as assembly) than other parts.
This in itself is not a problem as long as the necessary tools are available to do the interpretation. Typically, this involves the use of several different compilers, interpreters, and assemblers, each of which interprets a specific source language, and together create the system such that it is executable on the operational platforms.
However, the problem lies at a more fundamental level, that is, in situations where it is desired that there be communication between the source files themselves or common use of constants by several files using different software languages. This is evident in situations where it is necessary to define certain global system parameters prior to system generation time, in a manner that the parameters be available to source files of all languages. While every source language today has the ability to pass a parameter definition from a single place down to all instances of usage of that parameter, this parameter knowledge mechanism is always specific to the language itself. No such mechanism currently exists for providing this parameter knowledge across software language barriers.
In order to be able to set a global compile time parameter in a system to be generated from multiple source languages, therefore, one typically has to make multiple difinitions for that parameter, each one using the parameter knowledge mechanism for a specific source language. This leads to very inefficient software maintenance, for when that parameter is changed, it must be changed in all the places where it is defined. If perchance the parameter is changed in one place and not another, the consequences to the generated system can be disastrous and can be very difficult to detect. Since large software systems are typically generated with several thousand compile time parameters, the problem of maintaining these in a multilanguage environment assumes enormous proportions.
As as simple example of the above problem, consider two source files, one written in BASIC and one written in PASCAL, and assume that these two files are part of a large software system. Assume further that each of these files utilize a number of common constants including a constant called CONST1 in each file. This constant CONST1 might represent, for example, a maximum limit on a variable TEMP (temperature). Tables 1 and 2 show the example BASIC and PASCAL code respectively.
TABLE 1 ______________________________________ 10 REM PROGRAM TO MONITOR PROCESS . . . 100 LET CONST1 = 657 . . . 1700 IF TEMP &gt; CONST1 THEN GO TO 2000 . . . 2000 PRINT "WARNING - TEMPERATURE LIMIT EXCEEDED" 2001 PRINT "CURRENT BATCH DAMAGED. INITIALIZE PROCESS" 2002 END ______________________________________
TABLE 2 ______________________________________ Program Process --Control; Const Const1 = 675; {absolute maximum temp.} Const2 = 660; {ideal maximum temp.} Const3 = 650; {ideal minimum temp.} Const4 = 635; {absolute minimum temp.} . . . Procedure Control --Oven --Temperature; Begin If (Temp &gt; Const4) and (Temp &lt; Const3) Then Up --Temperature; If (Temp &gt;= Const3) and (Temp &lt;= Const2) Then Same --Temperature; If (Temp &gt; Const2) and (Temp &lt; Const1)Then Down --Temperature; . . . End. ______________________________________
In this simple example, the BASIC routine of TABLE 1 is a routine which monitors an industrial process including an oven temperature. The PASCAL routine of TABLE 2 is a routine, which may even be running on a different computer, which actually controls the industrial process including controlling the oven temperature. The PASCAL routine uses 4 constants representing limits on the oven temperature. This program's job is to maintain the temperature between temperatures Const1 and Const4, such range being acceptable for the process. In this case, the ideal temperature range is between the values of constants Const2 and Const3. If the temperature drops between temperatures Const3 and Const4, the program increases the oven temperature. If the temperature drops to between the temperatures Const1 and Const2, the program decreases the oven temperature. The monitoring program of TABLE 1 periodically checks the temperature of the oven and informs the operator that products have been damaged by excessive temperature if the temperature of the oven exceeds CONST1. The operator must then reinitialize the product process if the maximum temperature is exceeded.
Note that the monitoring program of TABLE 1 erronously indicates that the value of CONST1 is 657 rather than the correct value of 675. This is an error which could easily occur by simply transposing the last two digits of the value of CONST1 or by other human error or modification of the source file. The probability of such an error in consistency, of course, increases with the number of constants which must be shared between the two routines. In this simple example, the error could go completely undetected for a long period of time as long as the oven does not approach the upper end of the ideal range. During this time, however, large numbers of products processed at the upper end of an ideal range might be reported damaged by excessive temperatures when in fact they are not. This could result in excessive scrap in the process as well as loss of production time due to unnecessary reinitialization of the process. Since the system might appear to work correctly for a large portion of the time, the error may be extremely difficult and expensive to find and is likely to be attributed to hardware malfunction.
Of course in this simple example, the error would likely be noticed in testing the software. But even so, such errors are often difficult to find and can produce substantial development delays. This is especially the case when there are thousands of compile time constants which are shared. This is frequently the case in large software system development programs which use numerous software engineers any of whom may erroneously change a constant or fall to uniformity change a constant. Such seemingly minor errors can become disastrous in such circumstances. Clearly, what would be desirable is the ability to define a value for CONST1 in a single, central place, and pass this definition down to every source file that uses this parameter, even though such files might be written in different languages.
The present invention provides a mechanism for solving this problem at the expense of an additional preprocessing step in the development process. This invention provides a mechanism whereby it is possible to make a single definition for a global compile time parameter available to source files in many different languages. This provides a great advantage in software maintenance, to wit, that when the parameter is required to be changed, it is necessary to change its value only in one place, and the change would then be propagated down to all the files using the parameter, even if they are not all in the same source language. The mechanism described herein uses a known technique called "preprocessing", and extends its use into the area of the integration of multi-language software systems.
Although preprocessing is a known technique and in fact is provided for as a part of the "C" programming language, it has not been known to be applied to the area of multi-language software systems before. By using the same preprocessor on source files in multiple languages to pull in global parameter definitions from a common set of header files, integrity can be assured in the generation of software system products.